package com.lideru.backstage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lideru.backstage.entity.Message;
import com.lideru.backstage.entity.dto.dataDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lideru
 */
@Mapper
public interface MessageMapper extends BaseMapper<Message> {

    Page<Message> getDataListBySql(Page<Object> objectPage, String search, Long id);


    @Select("SELECT count(b.id) count, a.name FROM t_book a LEFT JOIN t_message b  on a.id =  b.book_id WHERE a.user_id = #{userId} GROUP BY b.book_id ORDER BY COUNT(b.book_id) DESC ;")
    List<dataDto> countMessage(Long userId);
}
